package Boundry;

import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.SystemColor;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.border.LineBorder;

import Controllers.GlobalData;
import Controllers.GuiManager;
import Controllers.UsersManager;
import javax.swing.SwingConstants;
import java.awt.Font;

public class Waiting extends JFrame implements ActionListener
{
	protected JLabel lbl_Info;
	protected JPanel panel;

	private static final long serialVersionUID = 1L;

	public Waiting() 
	{
	
	     
	    setEnabled(false);
	  	setAlwaysOnTop(true);
	  	this.setUndecorated(true);
	  	this.setSize(280, 100);
	  	
	  	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	  	
	  	int w = this.getSize().width;
	     int h = this.getSize().height;
	     int x = (dim.width-w)/2;
	     int y = (dim.height-h)/2;

	     // Move the window
	     this.setLocation(x, y);
	  	
	 	setIconImage(Toolkit.getDefaultToolkit().getImage(Splash.class.getResource("/GUI/Image/12_hardware_dock.png")));
	  	getContentPane().setLayout(new GridLayout(0, 1, 0, 0));
	  	
	  	panel = new JPanel();
	  	panel.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
	  	panel.setBackground(SystemColor.activeCaption);
	  	getContentPane().add(panel);
	  	panel.setLayout(null);
	  	
	  	JLabel lblNewLabel = new JLabel("New label");
	  	lblNewLabel.setBounds(2, 2, 276, 34);
	  	lblNewLabel.setIcon(new ImageIcon(Splash.class.getResource("/ICONS/logo.png")));
	  	panel.add(lblNewLabel);
	  	
	  	JLabel lblNewLabel_1 = new JLabel("");
	  	lblNewLabel_1.setBounds(106, 34, 48, 41);
	  	lblNewLabel_1.setIcon(new ImageIcon(Splash.class.getResource("/ICONS/bigrotation2.gif")));
	  	panel.add(lblNewLabel_1);
	  	
	  	lbl_Info = new JLabel("Loading . . . ", JLabel.CENTER);
	  	lbl_Info.setFont(new Font("Tahoma", Font.BOLD, 11));
	  	lbl_Info.setForeground(new Color(47, 79, 79));
	  	lbl_Info.setBounds(21, 75, 233, 14);
	  	panel.add(lbl_Info);
	    
	     this.addWindowListener(closeWindow);

	     setVisible(true);
	     toFront();
	}

	@Override
	public void actionPerformed(ActionEvent ae) 
	 {
	     System.exit(0);
	 }
	  
	 private static WindowListener closeWindow = new WindowAdapter(){
	  
		 public void windowClosing(WindowEvent e){
	         e.getWindow().dispose();
	     }
	 };
	 
	 public void kill()
	 {
		 this.setVisible(false);
			this.dispose();
	 }

}
